package com.bdqn.t350.ch11.service.imp;

import com.bdqn.t350.ch11.mapper.RoleRightMapper;
import com.bdqn.t350.ch11.service.RoleRightService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Set;

@Service
public class RoleRightServiceImp implements RoleRightService {

    @Resource
    RoleRightMapper roleRightMapper;

    @Transactional
    @Override
    public int batchInsert(Set<String> rightSet, Integer roleId) {
        if (rightSet.size() > 0) {
            return roleRightMapper.batchInsert(rightSet, roleId);
        } else {
            return 0;
        }
    }

    @Transactional
    @Override
    public int deleteByIds(Set<String> rightSet, Integer roleId) {
        if (rightSet.size() > 0) {
            return roleRightMapper.deleteByIds(rightSet, roleId);
        } else {
            return 0;
        }
    }

    @Override
    public int deleteAll(Integer roleId) {
        return roleRightMapper.deleteAll(roleId);
    }
}
